#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
using namespace std;
const int MAX_N = 5e4 + 5;
struct cir
{
	int x;
	int y;
	int r;
}c[MAX_N];
const int N = 999999;
typedef long long LL;
LL h[N];
int id[N];
bool st[N];
int n, m;

LL get_key(int x, int y)
{
	LL tmp = x * 1000000001ll + y;
	return tmp;
}

int find(int x, int y)
{
	LL key = get_key(x, y);
	int t = (key % N + N) % N;

	while (h[t] != -1 && h[t] != key)
	{
		if (++t == N)
			t = 0;
	}

	return t;
}

int sqr(int x)
{
	return x * x;
}

void dfs(int x, int y)
{
	int t = find(x, y);
	st[t] = true;

	int r = c[id[t]].r;
	for (int i = x - r; i <= x + r; i++)
	{
		for (int j = y - r; j <= y + r; j++)
		{
			if (sqr(i - x) + sqr(j - y) <= sqr(r))
			{
				if (!st[find(i, j)] && id[find(i, j)])
				{
					dfs(i, j);
				}
			}
		}
	}
}

int main()
{
	cin >> n >> m;

	memset(h, -1, sizeof h);

	for (int i = 1; i <= n; i++)
	{
		int x, y, r;
		cin >> x >> y >> r;
		c[i].x = x;
		c[i].y = y;
		c[i].r = r;

		int t = find(x, y);
		if (h[t] == -1)
		{
			h[t] = get_key(x, y);
		}

		if (!id[t] || c[id[t]].r < r)
		{
			id[t] = i;
		}
	}

	while (m--)
	{
		int x, y, r;
		cin >> x >> y >> r;
		for (int i = x - r; i <= x + r; i++)
		{
			for (int j = y - r; j <= y + r; j++)
			{
				int t = find(i, j);
				if (sqr(i - x) + sqr(j - y) <= sqr(r))
				{
					if (!st[t] && id[t])
					{
						dfs(i, j);
					}
				}
			}
		}
	}

	int ret = 0;
	for (int i = 1; i <= n; i++)
	{
		if (st[find(c[i].x, c[i].y)])
			ret++;
	}
	cout << ret;


	return 0;
}

/*
2 1
2 2 4
4 4 2
0 0 5
*/